
#include "Physics.h"
#include "SpriteList.h"
#include <iostream>

int PHYSICS_NotInside(int x1,int y1 ,int graf1, int x2, int y2, int graf2)
{
	int w1,h1,w2,h2, result = 0;
	
	w1 = SPRITELIST_GetWidth(graf1);
	h1 = SPRITELIST_GetHeight(graf1);

	w2 = SPRITELIST_GetWidth(graf2);
	h2 = SPRITELIST_GetHeight(graf2);

	if( (x1+w1) > (x2+w2) )
		result |= PHYSICS_RIGHT;

	if( x1 < x2 )
		result |= PHYSICS_LEFT;

	if( (y1+h1) > (y2+h2) )
		result |= PHYSICS_DOWN;

	if( y1 < y2 )
		result |= PHYSICS_UP;

	return result;
}

int PHYSICS_Collision(int x1,int y1 ,int graf1, int x2, int y2, int graf2)
{
	int w1,h1,w2,h2, result = 0;

	w1 = SPRITELIST_GetWidth(graf1);
	h1 = SPRITELIST_GetHeight(graf1);

	w2 = SPRITELIST_GetWidth(graf2);
	h2 = SPRITELIST_GetHeight(graf2);
	
	if( (x1+w1) >= x2 )
		result |= PHYSICS_RIGHT;
	
	if( (x2+w2) >= x1 )
		result |= PHYSICS_LEFT;

	if( (y1+h1) >= y2 )
		result |= PHYSICS_UP;

	if( (y2+h2) >= y1 )
		result |= PHYSICS_DOWN;

	if( (x1+w1) < x2 )
		result = 0;

	if( (x2+w2) < x1 )
		result = 0;

	if( (y1+h1) < y2)
		result = 0;

	if( (y2+h2) < y1)
		result = 0;

	return result;
}